#include <types.h>
#include <stdlib.h>
#include <video.h>

  


void putchar(char c)
{
  vputchar(c);
}



void putd(int num)
{
  uint_8 buff[20];
  int i = 0;
  
  if (num == 0)
  {
    putchar('0');
    return;
  }

  if(num < 0)
  {
    num = 0 - num;
    putchar('-');
  }
    
	  
  while(num)
  {
    i++;
    buff[i] = num % 10;
    num = num / 10;
  }

  while(i)
    putchar(buff[i--] + '0');
}



void putld(long int num)
{
  uint_8 buff[20];
  int i = 0;

  if (num == 0) {
    putchar('0');
    return;
  }
  
  if (num < 0) {
    num = 0 - num;
    putchar('-');
  }

  while(num)
  {
    i++;
    buff[i] = num % 10;
    num = num / 10;
  }

  while(i)
    putchar(buff[i--] + '0');

}

void putu(unsigned int num)
{
  uint_8 buff[20];
  int i = 0;
  if (num == 0) {
    putchar('0');
    return;
  }
  
  while(num)
  {
    i++;
    buff[i] = num % 10;
    num = num / 10;
  }

  while(i)
    putchar(buff[i--] + '0');
}


void putb(unsigned int num)
{
  uint_8 tmp[35];
  int i;

  if (num == 0) {
    putchar('0');
  } else {
    i=0;
    tmp[0]='0';
    while (num>0) {
      tmp[i++]='0'+(num & 1);
      num >>= 1;
    }
    for (i--;i>=0;i--)
      putchar(tmp[i]);
  }
}


void putx(int num)
{
  uint_8 tmp[20];
  int i;

  if (num == 0) {
    putchar('0');
  } else {
    i=0;
    tmp[i]='0';
    while (num>0) {
      if ((num&0xF)<0xA)
	tmp[i++]='0'+(num&0xF);
      else tmp[i++]='A'+(num&0xF)-10;
      num>>=4;
    }
    for (i--;i>=0;i--)
      putchar(tmp[i]);
  }
}

void puts(char *s)
{
  if(!s)
    return;

  while(*s)
    putchar(*s);
}




